package com.skycode7.servlet;

import com.skycode7.bean.NoticeBean;
import com.skycode7.dao.NoticeDao;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import java.util.List;

@WebServlet
public class NoticeServlet extends HttpServlet {
    @Override
    protected void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
            throws javax.servlet.ServletException, java.io.IOException {
        req.setCharacterEncoding("UTF-8");
        String sq = req.getParameter("page");
        int page = 1;
        if (sq == null && ! sq.equals("")){
            page = Integer.parseInt(sq);
        }
        NoticeDao noticeDao = new NoticeDao();
        List<NoticeBean> list = noticeDao.getNoticeList(page);
        req.setAttribute("list", list);
        req.getRequestDispatcher("/notice.jsp").forward(req, resp);
    }
}
